export function getWeekday(startDate, endDate) {
  // 校验参数
  if (!startDate || !endDate) {
    return 0;
  }
  let daysNum = 0;
  const startYearMonthDayStr = startDate.split(" ")[0];
  const endYearMonthDayStr = endDate.split(" ")[0];
  // 解析字符串
  const startYear = startDate.match(/(\d{4})-\d{2}-\d{2}/)[1];
  const startMonth = startDate.match(/\d{4}-(\d{2})-\d{2}/)[1];
  const startDay = startDate.match(/\d{4}-\d{2}-(\d{2})/)[1];
  const startHour = startDate.match(/(\d{1,2}):\d{1,2}/)[1];
  const startMinutes = startDate.match(/\d{1,2}:(\d{1,2})/)[1];
  const startTime = new Date();
  startTime.setFullYear(startYear);
  startTime.setMonth(startMonth - 1);
  startTime.setDate(startDay);
  startTime.setHours(startHour);
  startTime.setMinutes(startMinutes);
  startTime.setSeconds(0);
  startTime.setMilliseconds(0);
  const endYear = endDate.match(/(\d{4})-\d{2}-\d{2}/)[1];
  const endMonth = endDate.match(/\d{4}-(\d{2})-\d{2}/)[1];
  const endDay = endDate.match(/\d{4}-\d{2}-(\d{2})/)[1];
  const endHour = endDate.match(/(\d{1,2}):\d{1,2}/)[1];
  const endMinutes = endDate.match(/\d{1,2}:(\d{1,2})/)[1];
  const endTime = new Date();
  endTime.setFullYear(endYear);
  endTime.setMonth(endMonth - 1);
  endTime.setDate(endDay);
  endTime.setHours(endHour);
  endTime.setMinutes(endMinutes);
  endTime.setSeconds(0);
  endTime.setMilliseconds(0);
  const fullDayTime = 1000 * 60 * 60 * 24;
  const startTime1200 = new Date(startTime.valueOf());
  // startTime1200.setHours(12);
  // startTime1200.setMinutes(00);
  const endTime1200 = new Date(endTime.valueOf());
  // endTime1200.setHours(12);
  // endTime1200.setMinutes(00);
  let addTime = startTime1200.getTime();
  // 只计算跨天
  if (startYearMonthDayStr != endYearMonthDayStr) {
    while (addTime <= endTime1200.getTime()) {
      const currentDate = new Date(addTime);
      const day = currentDate.getDay();
      if (day == 6 || day == 0) {
        daysNum++;
      }
      addTime += fullDayTime;
    }
    return daysNum;
  } else {
    return daysNum;
  }
}
